<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button id="cancelReq" onclick="xhr.abort()">取消</button>
    <div id="cancelMsg"></div>
    <script>
      const xhr = new XMLHttpRequest();
      xhr.open("GET", "http://127.0.0.1:8081/tours");
      xhr.onload = function () {
        console.log(xhr.response);
      };
      xhr.onabort = function () {
        cancelMsg.innerHTML = '请求取消<a href="./2.html">刷新</a>';
      };
      xhr.send();

      // const cancelReq = document.getElementById("cancelReq");

      // cancelReq.onclick = function () {
      //   xhr.abort();
      // };
    </script>
  </body>
</html>
